
package com.itjob.scott.lesson05;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.itjob.scott.lesson04.JDBCUtil;
import com.itjob.scott.lesson04.JDBCUtil.CallParameter;

import oracle.jdbc.driver.OracleTypes;

public class CursorUtil {
	
	public static void callCursor() throws Exception {
		Connection connection = JDBCUtil.getConnection(JDBCUtil.DBMS_ORACLE);
		List<CallParameter> list = new ArrayList<JDBCUtil.CallParameter>();
		list.add(new CallParameter("sex","男",CallParameter.IN,Types.VARCHAR));
		list.add(new CallParameter("student",null,CallParameter.OUT,OracleTypes.CURSOR)); //出参是个游标类型
		
		Map<String, Object> map = JDBCUtil.call(connection, "{call pro_cursor(?,?)}", list);
		System.out.println(map);
		
		ResultSet rs =  (ResultSet) map.get("student");
		
		List<StudentEntity> ss = JDBCUtil.getBeans(StudentEntity.class, rs);
		for (StudentEntity s : ss) {
			System.out.println(s);
		}
		
		
	}
	

}
